package cn.wei.sdd.core.service.impl;

import cn.wei.sdd.core.pojo.entity.BannerInfo;
import cn.wei.sdd.core.mapper.BannerInfoMapper;
import cn.wei.sdd.core.service.BannerInfoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Wei
 * @since 2021-10-07
 */
@Service
public class BannerInfoServiceImpl extends ServiceImpl<BannerInfoMapper, BannerInfo> implements BannerInfoService {

    @Override
    public void addBannerInfo(BannerInfo bannerInfo) {
        baseMapper.insert(bannerInfo);
    }

    @Override
    public void lock(Long id, Integer status) {
        UpdateWrapper<BannerInfo> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("id",id).set("status",status);
        baseMapper.update(null,updateWrapper);
    }

    @Override
    public IPage<BannerInfo> listPage(Page<BannerInfo> pageParam) {

        return baseMapper.selectPage(pageParam,null);
    }

    @Override
    public List<BannerInfo> listAll() {

        return baseMapper.selectList(new QueryWrapper<BannerInfo>().eq("status",1));
    }
}
